# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2024/3/17
desc: 
sample: 
"""
#左开右闭（去掉） 默认步长 正数 升序（从小到大）
name = "testfan"
print(name[2:5:1]) # s。。a  stf ok
print(name[5:2]) #没数据
print(name[-5:-2]) # s。。a stf ok
print(name[-2:-5]) #没数据
print("步长为负数---")
#步长 负数 降序
print(name[2:5:-1]) #没有数据
print(name[5:2:-1]) #有数据  a。。。s   aft
print(name[-2:-5:-1])  #a。。s aft

print("-----for 1 10 --------")
for i in range(10):
    print(i,end=" ")

for i in range(1,11):
    print(i)

print("-----for 10 1 --------")
for i in range(10,0,-1):
    print(i)

print('---集合切片----')
data_list = ['极光', 'zhangsan', '李四', 'mtx', '王五']
print(data_list[0])
print(data_list[0:2])
print(data_list[1:])

name = "testfan"
print("省。。。")
print(name[:5])  #t..a testf
print(name[5:])  #an #默认结尾时候不参与闭合
print(name[:-2]) #t..a  testf
print(name[-2:]) #an
print(name[::])
print(name[::-1])

#set 没有下标 切片
data_list = {'极光','test', 'zhangsan', '李四', 'mtx', '王五'}
# print(data_list[0])
# print(data_list[1: 2])
for item in data_list:
    print(item)

data_list = ('极光', 'zhangsan', '李四', 'mtx', '王五')
print(data_list[4])
print(data_list[1:])


print("数据嵌套")
list1 = [{'name', '张三','age',20}, {'age', 25,'age1',18}, ['lunch_fee', 19.5,'age',15]]
for c1,c2,c3,c4 in list1:
    print(c1,c2,c3,c4)

for item in list1:
    for item2 in item:
        print(item2)